package com.hr.base;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.BinaryOperator;
import java.util.stream.Stream;

/**
 * @author Administrator
 * 流的终端操作
 */
public class StreamTerminal {
    public static void main(String[] args) {
        List<String> list = Arrays.asList("A", "B", "C");
        Stream<String> stream = list.stream();
        stream.forEach(System.out::println);

        long count = list.stream().count();
        System.out.println(count);

        Optional<String> min = list.stream().min((s1, s2) -> s1.compareToIgnoreCase(s2));
        System.out.println(min.get());
        boolean b = list.stream().allMatch(s -> s.length() > 5);
        System.out.println(b);
        System.out.println(list.stream().reduce(new BinaryOperator<String>() {
            @Override
            public String apply(String s, String s2) {
                return s + s2;
            }
        }).get());

    }
}
